<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>BOM对象中的本地存储-将数据存在用户的电脑上硬盘里，浏览器可以读取这些数据</p>
    <script>
        var name = 'tom'
        name = 'Tim'
        // console.log(name);
        // localStorage 本地存储 setItem用来保存数据,保存数据类型只能是字符串
        localStorage.setItem('name', JSON.stringify(name));
        // getItem 用来获取数据
        var data = localStorage.getItem('name');
        console.log(111, data);
        var list = localStorage.getItem('studentsList');
        console.log(JSON.parse(list));
        // 删除数据
        // localStorage.removeItem('name');
        // 全部删除
        // localStorage.clear()
        // =================
        // SessionStorage 会话存储
        sessionStorage.setItem('name', 'tom')
    </script>
</body>
</html>